home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / tcp_ip / jnos / jnos_src / udpcmd.c < prev    next >
C/C++ Source or Header  |  1994-04-17  |  2KB  |  75 lines

  1. /* UDP-related user commands
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. #ifdef MSDOS
  5. #include <dos.h>
  6. #endif
  7. #include "global.h"
  8. #include "mbuf.h"
  9. #include "netuser.h"
  10. #include "socket.h"
  11. #include "udp.h"
  12. #include "internet.h"
  13. #include "cmdparse.h"
  14. #include "commands.h"
  15.   
  16. static int doudpstat __ARGS((int argc,char *argv[],void *p));
  17.   
  18. static struct cmds DFAR Udpcmds[] = {
  19.     "status",   doudpstat,  0, 0,   NULLCHAR,
  20.     NULLCHAR,
  21. };
  22. int
  23. doudp(argc,argv,p)
  24. int argc;
  25. char *argv[];
  26. void *p;
  27. {
  28.     return subcmd(Udpcmds,argc,argv,p);
  29. }
  30. int
  31. st_udp(udp,n)
  32. struct udp_cb *udp;
  33. int n;
  34. {
  35.     if(n == 0)
  36. #ifdef UNIX
  37.         tprintf("&UCB Rcv-Q  Local socket\n");
  38.   
  39.     return tprintf("%8.8x%6u  %s\n",FP_SEG(udp),udp->rcvcnt,pinet(&udp->socket));
  40. #else
  41.     tputs("&UCB Rcv-Q  Local socket\n");
  42.   
  43.     return tprintf("%4.4x%6u  %s\n",FP_SEG(udp),udp->rcvcnt,pinet(&udp->socket));
  44. #endif
  45. }
  46.   
  47. /* Dump UDP statistics and control blocks */
  48. static int
  49. doudpstat(argc,argv,p)
  50. int argc;
  51. char *argv[];
  52. void *p;
  53. {
  54.     register struct udp_cb *udp;
  55.     register int i;
  56.   
  57.     for(i=1;i<=NUMUDPMIB;i++){
  58.         tprintf("(%2u)%-20s%10lu",i,
  59.         Udp_mib[i].name,Udp_mib[i].value.integer);
  60.         if(i % 2)
  61.             tputs("     ");
  62.         else
  63.             tputc('\n');
  64.     }
  65.     if((i % 2) == 0)
  66.         tputc('\n');
  67.   
  68.     tputs("&UCB Rcv-Q  Local socket\n");
  69.     for(udp = Udps;udp != NULLUDP; udp = udp->next){
  70.         if(st_udp(udp,1) == EOF)
  71.             return 0;
  72.     }
  73.     return 0;
  74. }
  75.